//
// Created by 紫霄 on 2020/5/6.
//

#ifndef LEETCODE_14_1_H
#define LEETCODE_14_1_H
#include <math.h>
class Solution {
public:
  int cuttingRope(int n) {
    if (n <= 3)
      return n - 1;
    int uniform = n / 3;
    int left = n % 3;
    int temp = 1;
    switch (left) {
    case 0:
      for (int i = 0; i < uniform; ++i) {
        temp = (temp * 3) % 1000000007;
      }
      break;
    case 1:
      for (int i = 0; i < uniform - 1; ++i) {
        temp = (temp * 3) % 1000000007;
      }
      temp = (4 * temp) % 1000000007;
      break;
    case 2:
      for (int i = 0; i < uniform; ++i) {
        temp = (temp * 3) % 1000000007;
      }
      temp = (2 * temp) % 1000000007;
      break;
    default:
      break;
    }
    return temp;
  }
};
#endif // LEETCODE_14_1_H
